﻿@using EcoTourEduca.BingYourMaps
@{
	Style.Include("map");
	Script.Require("jQuery");
	Script.Include("http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0");
	Script.Include("maplist.js");
    var mapIndex = (Context.Items["EcoTourEduca.BingYourMaps.Index"] as int?) ?? 0;
    Context.Items["EcoTourEduca.BingYourMaps.Index"] = mapIndex + 1;

	// Set size with units
	var width = (Model.MapWidth != null) ? Model.MapWidth + "pt" : "100%";
	var height = Model.MapHeight + "pt";

}
@using(Script.Foot()) 
{
    <script type="text/javascript">
        function initMap() 
        {
            var loc = newLocation(@Html.ToInvariantCultureString((float)Model.Latitude),
                                    @Html.ToInvariantCultureString((float)Model.Longitude));
            var map = newMap("BingLocation@(mapIndex)",
                        loc,
                        @Model.MapZoom,
                        "@(Ajax.JavaScriptStringEncode(Model.MapType))");
            var pin = newPin(loc, "@Model.PinIconsFolder", 
                        "@Ajax.JavaScriptStringEncode((string)Model.PinIcon)");
		    map.entities.push(pin);
	    }
	    $(window).load(initMap);
    </script>
}

<div id="BingLocation@(mapIndex)" 
    class="BingLocation" 
    style="position:relative; 
    width:@(width); 
    height:@(height);">
</div>